package com.fh.alipay.model.convert;


import lombok.experimental.UtilityClass;
import com.fh.alipay.po.User;
import com.fh.alipay.model.dto.UserDTO;
import com.fh.alipay.model.vo.UserVO;
import java.util.ArrayList;
import java.util.List;

/**
 * @author fh
 * @date 2022-05-03
 * @description 小程序管理用户转换类
 */

@UtilityClass
public class UserConvert {


    public static User toPO(UserDTO dto){
        User result = new User();
            result.setId(dto.getId());
            result.setUsername(dto.getUsername());
            result.setPassword(dto.getPassword());
            result.setUserType(dto.getUserType());
        return result;
    }

    public static UserVO toVO(User po){
        UserVO result = new UserVO();
                result.setId(po.getId());
                result.setUsername(po.getUsername());
                result.setPassword(po.getPassword());
                result.setUserType(po.getUserType());
            return result;
    }
    public static List<UserVO> toVO(List<User> pos){
        if(pos == null){
            return null;
        }
        List<UserVO> list = new ArrayList<>();
        for(User po:pos){
            list.add(toVO(po));
        }
        return list;
    }

    public static List<User> toPO(List<UserDTO> dtos){
        if(dtos == null) {
            return null;
        }
        List<User> list = new ArrayList<>();
        for(UserDTO dto:dtos) {
            list.add(toPO(dto));
        }
        return list;
    }


}
